<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<!--<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache"> -->
<meta http-equiv="Expires" co添加材料ntent="0">
<title></title>
<link href="css/login.css" type="text/css" rel="stylesheet">
<script src="js/jquery-2.1.4.js"></script>
<script src="js/vue.js"></script>
</head>
<body> 

<div class="login" style="margin-top:50px" id="addmaterials">
    <div class="message">材料添加</div>
    <div id="darkbannerwrap" ></div>
    
    <form action="javascript:void (0)" >
		<input name="action" value="login" type="hidden">
		<input class="top" id="materialName" placeholder="材料名称"  type="text">
		<input class="top" id="materialModel" placeholder="材料型号"  type="text">
		<input class="top" id="materialPrice" placeholder="材料价格"  type="text">
		<input class="top"  placeholder="材料图片地址"  type="file" name="myfile" id="img">
		<input class="top" id="materialSupplierTel" placeholder="材料商联系方式"  type="text">
		<input class="top" id="materialSupplier" placeholder="材料商"  type="text">
		<input class="top"  type="text" id="materialBak1"  list="list" placeholder="请选择阶段"/>
		<datalist  id="list">
			<option value="1">一阶段</option>
			<option value="2">二阶段</option>
			<option value="3">三阶段</option>
			<option value="4">四阶段</option>
			<option value="5">五阶段</option>
		</datalist>

		<hr class="hr15">
		<input  onclick="insertAccount()" value="确定添加" style="width:100%;" type="submit">
		<hr class="hr20">
		<!--<a onClick="alert('请联系管理员')">忘记密码</a>-->
	</form>

	
</div>
<!--图片添加-->
<script>
var date1=new Date();
var date2=new Date();
function insertAccount() {
		date1=date2;
		date2=new Date();
		if((date2.getTime()-date1.getTime()<5000)){
			alert("请不要重复提交")
		}else {
			var formData = new FormData();
			var pic = document.getElementById("img");


			formData.append("img", pic.files[0]);


		}
				formData.append( "materialName", $ ( "#materialName").val());
				formData.append( "materialModel",$("#materialModel").val());
				formData.append( "materialPrice",$("#materialPrice").val());
				formData.append( "materialSupplierTel",$("#materialSupplierTel").val());
				formData.append( "materialSupplier",$("#materialSupplier").val());
				formData.append( "materialBak1",$("#materialBak1").val());
			$.ajax({
				type: "post",
				url: "/onedecmaterials/upload/insetMaterisalss",
				data: formData,
				dataType: 'json',
				processData:false,
				contentType:false,
				success: function (data) {
					if(data.code==200){
						alert("添加成功")
						history.go(0);
					}

				},
			});




}
</script>
<script>
	var app= new Vue({
		el: "#addmaterials",
		data: {
			example: {
				materialName: '',
				materialModel: '',
				materialPrice: '',
				materialImgUrl: '',
				materialSupplierTel: '',
				materialSupplier: '',
				materialBak1:""
			},
		},
		methods: {
			insetMaterials:function () {
				var _this=this;
				$.ajax({
					type: "post",
					url: "/onedecmaterials/insetMaterials",
					data: _this.example,
					dataType: 'json',
					success: function (data) {
						if(data.code==200){
							alert("添加成功")
						}

					},
				});
			}
		}
	})
</script>
</body>
</html>